/**
 * @date 6:07:45 PM
 * EducationSchoolDaoImpl.java
 * Administrator
 * TODO
 */
package com.qs.education.bean.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.qs.education.bean.dao.IEducationSchoolDao;
import com.qs.education.bean.entity.EducationSchool;
/**
 * @class EducationSchoolDaoImpl	
 * @author Warren
 * @description
 * @date Nov 7, 2018 
 */
@Repository
public class EducationSchoolDaoImpl extends BaseDaoImpl<EducationSchool> implements IEducationSchoolDao{
	
	/**
	 * @author Warren
	 * @param province 省
	 * @param city	市
	 * @param area	区
	 * @return EducationSchool
	 * @description 根据省市区查询所有学校
	 * @date Nov 8, 2018
	 */
	@Override
	public List<EducationSchool> findSchoolByProvinceAndCityAndArea(String province, String city, String area ,String name) {
		String jql = "from EducationSchool es where 1=1";
		Map<String,Object> params = new HashMap<String,Object>();
		if(province!=null) {
			params.put("province", province);
			jql = jql + " and province=:province";
		}
		if(city!=null) {
			params.put("city", city);
			jql = jql + " and city=:city";
		}
		if(area!=null) {
			params.put("area", area);
			jql = jql + " and area=:area";
		}				//特例：直辖市：例：北京市朝阳区	前端传过来的是北京市北京市朝阳区
		if(name!=null) {
			params.put("name", "%"+name+"%");
			jql = jql + " and name like :name";
		}
		List<EducationSchool> list = query(jql,EducationSchool.class,params);
		return list;
	}
	
}
